package com.rainxing.cockpit.modules.quartz.job.hotlineTask;

import com.rainxing.cockpit.modules.hotline.service.HotlineService;
import com.rainxing.cockpit.redis.RedisHandle;
import com.rainxing.cockpit.utils.CustomDate;
import lombok.extern.slf4j.Slf4j;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.quartz.QuartzJobBean;

import java.util.Map;

/**
 * @Auther: ybzhu
 * @Date: 2018/8/17 12:40
 * @Description: 热线案由Top10
 */
@Slf4j
public class HotLineTop10Task extends QuartzJobBean {
    //注入redis接口
    @Autowired
    private RedisHandle redisHandle;
    @Autowired
    private HotlineService hotlineService;

    @Override
    protected void executeInternal(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        log.info("热线定时任务二：热线案由Top10");
        String startTime = (String) redisHandle.get("startTime");
        String endTime = (String) redisHandle.get("endTime");
        Map<String, String> startAndEnd = CustomDate.getStartAndEnd(startTime, endTime);
        hotlineService.hotLineTop10(startAndEnd.get("startTime"), startAndEnd.get("endTime"));
        hotlineService.getReportTop3(startAndEnd.get("startTime"), startAndEnd.get("endTime"));
    }
}
